package com.dgut.lab.security;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Collections;

public class DgutOAuth2LoginAuthenticationToken extends AbstractAuthenticationToken {
    private String token;
    private Object principal;
    private HttpServletRequest request;

    public DgutOAuth2LoginAuthenticationToken(String token,HttpServletRequest request){
        super(Collections.emptyList());
        this.token = token;
        this.request = request;
    }

    public DgutOAuth2LoginAuthenticationToken(Object principal, Collection<? extends GrantedAuthority> authorities){
        super(authorities);
        this.principal = principal;
        this.setAuthenticated(true);
    }

    public String getToken() {
        return token;
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    @Override
    public Object getCredentials() {
        return "";
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }
}
